<?php
/**
 * 算力矿机
 */
namespace app\common\model;
use think\Model;

class MiningArithmetical extends Model
{
    protected $name = 'mining_arithmetical';

    /**
     * 查询所有算力矿机
     * @param array $where  查询条件
     * @param string $filed 指定字段
     * @param string $order 排序
     * @return MiningArithmetical[]|array|\think\Collection
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getListAll($where = [],$field = '', $order = 'id desc', $language = ''){
        $field = !empty($field) ? $field : 'id,pid,currency,money,max_possess,quantity_sold,available_for_sale,type,arithmetical,pledge_money,pledge_multiple,return_pledge,pledge_currency';
        $field .= ','.file_language('name',$language).','.file_language('label',$language).','.file_language('pic',$language);
        $data = self::where($where)->field($field);
        return $data->order($order)->select();
    }

    /**
     * 查询算力矿机详情
     * @param $id
     * @param string $field 字段
     * @return MiningArithmetical|array|mixed|Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getDetails($id,$language = ''){
        $field = 'id,pid,currency,money,max_possess,quantity_sold,available_for_sale,type,arithmetical,pledge_money,pledge_multiple,return_pledge,pledge_currency,push_arithmetical,indirect_arithmetical';
        if($language){
            $field .= ','.file_language('name',$language).','.file_language('label',$language).','.file_language('pic',$language);
        }else{
            $field .= ',name,e_name,t_name,label,e_label,t_label,pic,e_pic,t_pic';
        }

        $data = self::where('id',$id)->field($field)->order('id desc')->find();
        return $data;
    }

}